function copyrightRowRender(copyright) {
    if (copyright === null) {
        siteHtml.copyright = 2;
        copyright = 2;
    }
    $("#copyright_row li").removeClass("active");
    $("#copyright_row li[data=" + copyright + "]").addClass("active");
    siteHtml.copyright = copyright;
}

function redirectHkzsRowRender(hkzs_redirect) {
    $("#hkzs_redirect_row li").removeClass("active");
    $("#hkzs_redirect_row li[data=" + hkzs_redirect + "]").addClass("active");
    siteHtml.hkzs_redirect = hkzs_redirect;
}

function wechatUnitRowRender(unit_type) {
    $("#wechat_unit_lists li").removeClass("active");
    $("#wechat_unit_lists li[data=" + unit_type + "]").addClass("active");
    siteHtml.unit_type = unit_type;
    $("#wechat_hkzs").hide();
    $("#wechat_yxt").hide();
    $("#wechat_mini").hide();
    $("#wechat_"+unit_type).show();
}

function firstLoadPage() {
    // 打开落地页加载组件
    siteHtml = JSON.parse($("#siteHtml").val());
    copyrightRowRender(siteHtml.copyright);
    $("#site_lists_detial").attr("href","/admin/links_lists/links_lists_detial/"+siteHtml.links_id);

    // 营销通小程序加粉
    // usersSiteComment("load");

    $("#title").val(siteHtml.title);
    $("#site_html_title").text(siteHtml.title);
    if ($(".htmldom-activity").length > 0) {
        var firstDomId = $(".htmldom-activity")[0].id;
        if ($(".htmldom-activity").hasClass("site-button-bottom")) {
            $(".site-button-top").removeClass("htmldom-activity");
            $(".site-button-right").removeClass("htmldom-activity");
        } else if ($(".htmldom-activity").hasClass("site-button-top")) {
            $(".site-button-bottom").removeClass("htmldom-activity");
            $(".site-button-right").removeClass("htmldom-activity");
        } else if ($(".htmldom-activity").hasClass("site-button-right")) {
            $(".site-button-top").removeClass("htmldom-activity");
            $(".site-button-bottom").removeClass("htmldom-activity");
        }
    } else {
        var firstDomId = $(".edit-htmldom")[0].id;
    }
    $("#hkzs_load_lists li").removeClass("active");
    $("#hkzs_load_lists li[data="+siteHtml.redirect_type+"]").addClass("active");
    renderEdit(firstDomId);
}

function renderEdit(id) {
    htmldomid = id;
    var platfrom = $("#" + id).attr("platfrom");
    var platfrom_detial = $("#" + id).attr("platfrom_detial");
    $("#" + id).addClass("htmldom-activity");
    $(".edit-right-from").hide();
    editRightTitle(platfrom);
    if (platfrom == "img") {
        $("#edit_right_img").show();
        var imgsrc = $("#" + id + " img").attr("src");
        $("#image_show").attr("src", imgsrc).show();
        $("#img_url").val("");
        var atag = $("#" + htmldomid).children("a");
        if (atag.length >= 1) {
            var imglink = $("#" + id + " a").attr("href");
            $("#img_url").val(imglink);
        } else {
            $("#img_url").val("");
        }
    } else if (platfrom == "form") {
        $("#edit_right_form").show();
        $("#edit_right_form_info").show();
        $("#edit_right_form_style").hide();
        var form_id = $("#form_id_" + htmldomid).val();
        var form_method = $("#form_method_" + htmldomid).val();
        var form_method_text = $("#form_method_text_" + htmldomid).val();
        $("#unit_form_select").val(form_id);
        $("#unit_form_method").val(form_method);
        if (form_method == "alert") {
            $("#unit_form_method_alert").show();
            $("#unit_form_method_wechat").hide();
            $("#unit_form_method_lists li").eq(0).removeClass("active");
            $("#unit_form_method_lists li").eq(1).addClass("active");
        } else {
            $("#unit_form_method_alert").hide();
            $("#unit_form_method_wechat").show();
            $("#unit_form_method_lists li").eq(0).addClass("active");
            $("#unit_form_method_lists li").eq(1).removeClass("active");
        }
        $("#unit_form_method_text").val(form_method_text);
    } else if (platfrom == "wechat") {
        if (platfrom_detial == "wechat_img" || platfrom_detial == "wechat_top_img" || platfrom_detial == "wechat_bottom_img") {
            $("#wechat_image_row").show();
            $("#wechat_animation_row").hide();
            $("#wechat_color_row").hide();
            var imgsrc = $("#" + id + " img").attr("src");
            $("#wechat_image_show").attr("src", imgsrc).show();
        } else {
            $("#wechat_image_row").hide();
            $("#wechat_animation_row").show();
            $("#wechat_color_row").show();
        }
        $("#edit_right_wechat").show();

        // 按钮样式 Start
        var buttonATag = $("#" + htmldomid).children("a");
        if (buttonATag.length >= 1) {
            var btnDom = $("#" + id + " a");
        } else {
            var btnDom = $("#" + id + " div");
        }
        $("#wechat_animation_lists li").show();
        $("#edit_right_wechat_info").show();
        $("#edit_right_wechat_style").hide();
        wechatUnitRowRender(siteHtml.unit_type);
        if (btnDom.hasClass("wechat_one")) {
            var wechat_text = $("#" + id + " div font").text();
            $("#wechat_text_row").show();
            $("#wechat_text").val(wechat_text);
            $("#wechat_text_row label").text("按钮文案:");
            $("#wechat_notice_row label").text("提示文案:");
            $("#wechat_notice_row").hide();
            $("#wechat_describe_color_row").hide();
            $("#wechat_border_row").show();
            $("#wechat_icon_row").show();
            $("#wechat_size_row").show();
            var btnBackgroundColor = btnDom.css("background-color");
            var btnColor = btnDom.css("color");
            var btnDescribeColor = "";
        } else if (btnDom.hasClass("wechat_two")) {
            var echat_notice = $("#" + id + " div .left").text();
            var wechat_text = $("#" + id + " div .right font").text();
            $("#wechat_text_row label").text("按钮文案:");
            $("#wechat_notice_row label").text("提示文案:");
            $("#wechat_text_row").show();
            $("#wechat_text").val(wechat_text);
            $("#wechat_notice_row").show();
            $("#wechat_notice").val(echat_notice);
            $("#wechat_animation_lists li").eq(2).hide();
            $("#wechat_describe_color_row").show();
            $("#wechat_border_row").hide();
            $("#wechat_icon_row").show();
            $("#wechat_size_row").show();
            var btnBackgroundColor = $("#" + id + " div .right").css("background-color");
            var btnColor = $("#" + id + " div .right").css("color");
            var btnDescribeColor = $("#" + id + " div .left").css("color");
        } else if (btnDom.hasClass("wechat_three")) {
            var wechat_notice = $("#" + id + " div .left").text();
            var wechat_text = $("#" + id + " div .right font").text();
            $("#wechat_text_row label").text("按钮文案:");
            $("#wechat_notice_row label").text("提示文案:");
            $("#wechat_text_row").show();
            $("#wechat_text").val(wechat_text);
            $("#wechat_notice_row").show();
            $("#wechat_notice").val(wechat_notice);
            $("#wechat_animation_lists li").eq(1).hide();
            $("#wechat_describe_color_row").show();
            $("#wechat_border_row").hide();
            $("#wechat_icon_row").show();
            $("#wechat_size_row").show();
            var btnBackgroundColor = $("#" + id + " div .right").css("background-color");
            var btnColor = $("#" + id + " div .right").css("color");
            var btnDescribeColor = $("#" + id + " div .left").css("color");
        } else if (btnDom.hasClass("wechat_four")) {
            $("#wechat_text_row label").text("微信提示:");
            $("#wechat_notice_row label").text("引导说明:");
            var wechat_text = $("#" + id + " .wechat_title font").text();
            var wechat_notice = $("#" + id + " .wechat_describe").text();
            $("#wechat_text_row").show();
            $("#wechat_text").val(wechat_text);
            $("#wechat_notice_row").show();
            $("#wechat_notice").val(wechat_notice);
            $("#wechat_animation_lists li").eq(2).hide();
            $("#wechat_describe_color_row").show();
            $("#wechat_border_row").hide();
            $("#wechat_icon_row").show();
            $("#wechat_size_row").show();
            var btnBackgroundColor = $("#" + id + " div .right").css("background-color");
            var btnColor = $("#" + id + " div .right").css("color");
            var btnDescribeColor = $("#" + id + " div .left").css("color");
        } else {
            $("#wechat_text_row").hide();
            $("#wechat_notice_row").hide();
            $("#wechat_animation_lists li").eq(1).hide();
            $("#wechat_describe_color_row").hide();
            $("#wechat_size_row").hide();
            $("#wechat_icon_row").hide();
            $("#wechat_border_row").hide();
            $("#wechat_icon_row").hide();
            $("#wechat_size_row").hide();
            var btnBackgroundColor = $("#" + id + " div").css("background-color");
            var btnColor = $("#" + id + " div").css("color");
            var btnDescribeColor = "";
        }

        $("#wechat_animation_lists li").removeClass("active");
        if (btnDom.hasClass("animation-fullbeat")) {
            $("#wechat_animation_lists li").eq(2).addClass("active");
        } else if (btnDom.hasClass("animation-textbeat")) {
            $("#wechat_animation_lists li").eq(1).addClass("active");
        } else {
            $("#wechat_animation_lists li").eq(0).addClass("active");
        }
        // 修改按钮颜色
        spectrumSetInputColor("wechat_background_color", btnBackgroundColor);
        spectrumSetInputColor("wechat_color", btnColor);
        spectrumSetInputColor("wechat_describe_color", btnDescribeColor);
        // 修改字号大小
        var fontSize = btnDom.css("font-size");
        $("#wechat_size_lists li").removeClass("active");
        if (fontSize == "20px") {
            $("#wechat_size_lists li").eq(1).addClass("active");
        } else {
            $("#wechat_size_lists li").eq(0).addClass("active");
        }

        if (btnDom.hasClass("wechat_one")) {
            var borderRadius = btnDom.css("border-radius");
            borderRadius = parseInt(borderRadius.replace("px", ""));
            $("#wechat_border_lists li").removeClass("active");
            if (borderRadius < 10) {
                $("#wechat_border_lists li").eq(1).addClass("active");
            } else {
                $("#wechat_border_lists li").eq(0).addClass("active");
            }
        }
        // 修改字号大小
        $("#wechat_icon_lists li").removeClass("active");
        if ($("#" + id + " i").is(":visible")) {
            $("#wechat_icon_lists li").eq(0).addClass("active");
        } else {
            $("#wechat_icon_lists li").eq(1).addClass("active");
        }
        // 按钮样式 End
    } else if (platfrom == "button") {
        if (platfrom_detial == "button_img" || platfrom_detial == "button_top_img" || platfrom_detial == "button_bottom_img") {
            $("#button_image_row").show();
            $("#button_animation_row").hide();
            $("#button_color_row").hide();
            var imgsrc = $("#" + id + " img").attr("src");
            $("#button_image_show").attr("src", imgsrc).show();
        } else {
            $("#button_image_row").hide();
            $("#button_animation_row").show();
            $("#button_color_row").show();
        }
        $("#edit_right_button").show();

        // 按钮样式 Start
        $("#button_animation_lists li").removeClass("active");
        var buttonATag = $("#" + htmldomid).children("a");
        if (buttonATag.length >= 1) {
            var btnDom = $("#" + id + " a");
        } else {
            var btnDom = $("#" + id + " div");
        }
        if (btnDom.hasClass("site-button-fullbeat")) {
            $("#button_animation_lists li").eq(2).addClass("active");
        } else if (btnDom.hasClass("site-button-textbeat")) {
            $("#button_animation_lists li").eq(1).addClass("active");
        } else {
            $("#button_animation_lists li").eq(0).addClass("active");
        }
        var btnBackgroundColor = btnDom.css("background-color");
        spectrumSetInputColor("button_background_color", btnBackgroundColor);
        var btnColor = btnDom.css("color");
        spectrumSetInputColor("button_color", btnColor);
        // 按钮样式 End

        // 按钮操作设置默认值 Start
        var onclicktype = $("#" + id).attr("onclick");
        $("#button_method_lists li").removeClass("active");
        if (typeof(onclicktype) == "undefined") {
            var buttonurl = $("#" + id + " a").attr("href");
            $("#button_url_input").val(buttonurl);
            buttonTypeRender("url");
            $("#button_method_lists li").eq(0).addClass("active");
        } else {
            if (onclicktype.indexOf("simpleSubmit") != -1) {
                $("#button_method_lists li").eq(1).addClass("active");
                buttonTypeRender("simpleSubmit");
            } else {
                $("#button_method_lists li").eq(2).addClass("active");
                buttonTypeRender("showFrom");
            }
        }
        // 按钮操作设置默认值 End
    } else if (platfrom == "text") {
        $("#edit_right_text").show();
        $("#edit_right_text_info").show();
        $("#edit_right_text_style").hide();
        if (platfrom_detial == "rich") {
            $("#edit_right_text_simple").hide();
            $("#edit_right_text_rich").show();
            $("#edit_right_text_comment").hide();
            var defaulthtml = $("#"+htmldomid+" div").html();
            editor.setHtml(defaulthtml);
        } else if (platfrom_detial == "comment") {
            $("#edit_right_text_simple").hide();
            $("#edit_right_text_rich").hide();
            $("#edit_right_text_comment").show();
            var textTitleColor = $("#"+htmldomid+" .title").css("color");
            var textTitleSize = $("#"+htmldomid+" .title").css("font-size");
            var comment_id = $("#"+htmldomid+" .title").attr(id);
            $("#site_comment_select").val(comment_id);
            $("#header_size_lists li").removeClass("active");
            if (textTitleSize == "18px") {
                $("#header_size_lists li[data=default]").addClass("active");
            } else if (textTitleSize == "20px") {
                $("#header_size_lists li[data=big]").addClass("active");
            } else {
                $("#header_size_lists li[data=superbig]").addClass("active");
            }
            spectrumSetInputColor("text_header_color", textTitleColor);
        } else {
            $("#edit_right_text_simple").show();
            $("#edit_right_text_rich").hide();
            $("#edit_right_text_comment").hide();
            $("#text_header_title").val($("#"+htmldomid+" .title").text());
            $("#text_header_editor").val($("#"+htmldomid+" .editor").text());
            $("#text_header_time").val($("#"+htmldomid+" .time").text());
            var textTitleColor = $("#"+htmldomid+" .title").css("color");
            var textTitleSize = $("#"+htmldomid+" .title").css("font-size");
            $("#header_size_lists li").removeClass("active");
            if (textTitleSize == "18px") {
                $("#header_size_lists li[data=default]").addClass("active");
            } else if (textTitleSize == "20px") {
                $("#header_size_lists li[data=big]").addClass("active");
            } else {
                $("#header_size_lists li[data=superbig]").addClass("active");
            }
            spectrumSetInputColor("text_header_color", textTitleColor);

            if (platfrom_detial == "gzh_head") {
                $("#text_header_come_row").show();
                $("#text_header_head_row").hide();
                $("#text_header_come").val($("#"+htmldomid+" .come").text());
                $("#text_header_link").val($("#"+htmldomid+" .come").attr("href"));
            } else if (platfrom_detial == "jrtt_head") {
                $("#text_header_come_row").hide();
                $("#text_header_head_row").show();
                var head_img = $("#"+htmldomid+" img").attr("src");
                $("#head_img").val(head_img);
                $("#head_img_show").attr("src",head_img);
            }
        }
    } else {
        return;
        if ($(".htmldom-activity").length > 0) {
            var firstDomId = $(".htmldom-activity")[0].id;
            renderEdit(firstDomId);
        } else {
            if ($(".edit-htmldom").length > 0) {
                var firstDomId = $(".edit-htmldom")[0].id;
                renderEdit(firstDomId);
            } else {

            }
        }
    }
}
